//
//  Function.m
//  Computer
//
//  Created by qianfeng on 15/10/20.
//  Copyright © 2015年 qianfeng. All rights reserved.
//

#import "Function.h"

@implementation Function

+(void)saveValue:(id)value forKey:(NSString *)key{
    
    //使用NSUserDefaults 存储数据
    [[NSUserDefaults standardUserDefaults] setValue:value forKey:key];
}
+(id)getValueForKey:(NSString *)key{
    //取出NSUserDefaults数据
    return [[NSUserDefaults standardUserDefaults] valueForKey:key];
}
+(UIBarButtonItem *)barButtonTitle:(NSString *)title image:(NSString *)image target:(id)target sel:(SEL)selector{
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    btn.frame = CGRectMake(0, 0, 44, 30);
    [btn setTitle:title forState:UIControlStateNormal];
    [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    btn.titleLabel.font = [UIFont systemFontOfSize:14];
    [btn setBackgroundImage:[UIImage imageNamed:image] forState:UIControlStateNormal];
    [btn addTarget:target action:selector forControlEvents:UIControlEventTouchUpInside];
    
    UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc]initWithCustomView:btn];
    return barButtonItem;
}
@end
